#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void printVector(const vector<int>& v)
{
    for(auto& i:v)
    {
        cout << i << " ";
    }
    cout << endl;
}

class Solution {
public:
    int searchInsert(vector<int>& nums, int target) 
    {
        int left = 0;
        int right = nums.size()-1;
        while(left<=right)
		{	
			if(target<nums[right])
			{
                cout << "right--\t" << right << endl;;
				right--;
			}
            else if(target>nums[left])
            {
                cout << "left++\t" << left << endl;
                left++;
            }
            else if(target== nums[left])
            {
                cout << "left\t" << left << endl;
                return left;
            }
            else if(target == nums[right])
            {
                cout << "right\t" << right << endl;
                return right;
            }
		}
        return left;
    }
};
int main()
{
    vector<int> v1 ={1,3,5,6};
    Solution s;
    cout << "resulet ="<<s.searchInsert(v1,0);
    return 0;
}

